home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Guides / PicsData / Rexx / PZ_MakePic_BW.rexx < prev    next >
OS/2 REXX Batch file  |  1993-11-11  |  3KB  |  164 lines

  1. /*
  2. **  $VER: $Id: PZ_MakePic_BW.rexx,v 5.0 1993/11/12 01:15:10 chris Exp $
  3. **  Copyright (C) 1992, 1993 by Christian A. Weber, Zürich, Switzerland.
  4. **  REXX script internally used by PicZoo. Do not start manually.
  5. **
  6. **  You may wish to change MAXMEM for ADPro if you don't have enough RAM,
  7. **  and the delay after loading if you have a slow HD :)
  8. */
  9.  
  10. options results
  11. arg adprodir filename maxwidth maxheight
  12. address 'ADPro'
  13.  
  14.  
  15. /*
  16. ** Make sure ADPro is running
  17. */
  18. IF ~show(ports,'ADPro') THEN
  19. DO
  20.     Address COMMAND 'C:Assign ADPRO: '||adprodir
  21.     Address COMMAND 'Run >NIL: ADPRO:ADPro MAXMEM=5000000 BEHIND'
  22.     Address COMMAND 'C:Wait 5'
  23.     IF ~show(ports,'ADPro') THEN EXIT
  24. END
  25.  
  26.  
  27. /*
  28. ** Screen types for ADPro
  29. */
  30. LORES        = 0
  31. HIRES        = 1
  32. LACE        = 2
  33. PAL        = 4
  34. XOVERSCAN    = 8
  35. YOVERSCAN    = 16
  36.  
  37. HIRESBIT    = 0
  38. LACEBIT        = 1
  39.  
  40.  
  41. /*
  42. ** Now load the picture ...
  43. */
  44. SCREEN_TYPE    LORES
  45. LFORMAT        'UNIVERSAL'
  46. LOAD        filename
  47.  
  48. IF RC == 0 THEN DO
  49.  
  50.     /*
  51.     ** Get the picture size
  52.     */
  53.     XSIZE
  54.     origwidth  = ADPRO_RESULT
  55.     YSIZE
  56.     origheight = ADPRO_RESULT
  57.  
  58.  
  59.     /*
  60.     **  Make a text string of the picture mode and size, and store it
  61.     **  in an environment variable
  62.     */
  63.     IMAGE_TYPE
  64.     type = WORD(ADPRO_RESULT,1)
  65.     if type = "GRAY" THEN DO
  66.         type = "G (" || origwidth || "x" || origheight || ")"
  67.     END
  68.     ELSE DO
  69.         type = "C (" || origwidth || "x" || origheight || ")"
  70.     END
  71.     Address COMMAND SetEnv PICZOO_IMAGETYPE type
  72.  
  73.  
  74.     /*
  75.     ** If we have an interlaced lo-res or a non-interlaced hi-res
  76.     ** picture, we must correct the aspect ratio accordingly.
  77.     ** We do this by changing orgwidth or orgheight.
  78.     */
  79.     SCREEN_TYPE
  80.     viewmode = ADPRO_RESULT
  81. /*
  82.     IF BITTST(viewmode, HIRESBIT) THEN DO
  83.         origwidth = origwidth / 2
  84.         Say 'Hi-Res.'
  85.     END
  86.  
  87.     IF BITTST(viewmode, LACEBIT) THEN DO
  88.         origheight = origheight / 2
  89.         Say 'Interlaced.'
  90.     END
  91. */
  92.     IF origwidth > origheight THEN DO
  93.         width  = maxwidth
  94.         height = (origheight * maxwidth) / origwidth
  95.     END
  96.     ELSE DO
  97.         width  = (origwidth * maxheight) / origheight
  98.         height = maxheight
  99.     END
  100.  
  101.  
  102.     /*
  103.     ** Set the palette to match the PicZoo screen
  104.     */
  105.     POFFSET        0
  106.     PUSED        16
  107.     PTOTAL        16
  108.     POFFSET        0
  109.     PPOKE         0 170 170 170
  110.     PPOKE         1   0   0   0
  111.     PPOKE         2 255 255 255
  112.     PPOKE         3 255   0 255
  113.     PPOKE         4  34  34  34
  114.     PPOKE         5  51  51  51
  115.     PPOKE         6  68  68  68
  116.     PPOKE         7  85  85  85
  117.     PPOKE         8 102 102 102
  118.     PPOKE         9 119 119 119
  119.     PPOKE        10 136 136 136
  120.     PPOKE        11 153 153 153
  121.     PPOKE        12 187 187 187
  122.     PPOKE        13 204 204 204
  123.     PPOKE        14 221 221 221
  124.     PPOKE        15 238 238 238
  125.     PSTATUS        LOCKED
  126.  
  127.  
  128.     /*
  129.     ** Now we convert the image to grey and scale it to width/height
  130.     */
  131.     OPERATOR    COLOR_TO_GRAY
  132.     ABS_SCALE    width height
  133.     RENDER_TYPE    16
  134.  
  135.  
  136.     /*
  137.     ** Make sure we get the best dynamic range
  138.     */
  139.     OPERATOR    DYNAMIC_RANGE 0 255
  140.  
  141.  
  142.     /*
  143.     ** Render the image with Floyd-Steinberg dithering
  144.     */
  145.     DITHER        1        /* Floyd-Steinberg */
  146.     SCREEN_TYPE    HIRES + LACE
  147.     EXECUTE
  148.  
  149.  
  150.     /*
  151.     ** Now save the image as a temp file, where PicZoo can get it.
  152.     */
  153.     SFORMAT        'IFF'
  154.     SAVE        'T:__PicZooTmp.iff' 'IMAGE'
  155.  
  156. END
  157. ELSE DO
  158.     /*
  159.     ** LOAD returned an error
  160.     */
  161.     say filename || ': not a picture'
  162. END
  163.  
  164.